<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>书籍捐赠明细列表</title>
<link rel="icon" href="favicon.ico" type="image/ico">

<link href="/Public/Admin/css/bootstrap.min.css" rel="stylesheet">
<link href="/Public/Admin/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/Public/Admin/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
<link href="/Public/Admin/css/style.min.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-toolbar d-flex flex-column flex-md-row">
          <div class="toolbar-btn-action">
            <!--<a class="btn btn-primary m-r-5" href="?c=Donate&a=addDonateList"><i class="mdi mdi-plus"></i> 新增</a>-->
          </div>
        </div>
        <div class="card-body">
          
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                 
                  <th>ID</th>
                  <th>捐书记录ID</th>
                  <th>书名</th>
                  <th>数量</th>
                  <th>ISBN</th>
				  <th>状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
				  
				  <?php foreach($arrs as $arr){?>
				  
                <tr> 
				  <td><?php echo $arr['donate_book_detail_id'];?></td>
                  <td><?php echo $arr['donate_book_id'];?></td>
                  <td><?php echo $arr['book_name'];?></td>
                  <td><?php echo $arr['book_count'];?></td>
                  <td><?php echo $arr['isbn'];?></td>
				  <td><?php if($arr['status']==0){?>
					<span class="badge badge-warning">未入库</span>
					<?php }else if($arr['status']==1){?>
					<span class="badge badge-info">已入库</span>
					<?php }else{?>
					<span class="badge badge-muted">异常</span>
					<?php }?>
					</td>
                  <td>
                    <div class="btn-group">
                      <!--a class="btn btn-xs btn-default" href="?c=Donate&a=donateBookDetailList&id=<?php echo $arr['donate_book_id'];?>" title="" data-toggle="tooltip" data-original-title="编辑"><i class="mdi mdi-pencil"></i></a-->
					  <?php if($arr['status']==0){?>
					  <a class="btn btn-xs btn-default ajax-get confirm" href="?c=Donate&a=setDonateBookDetailIn&id=<?php echo $arr['donate_book_detail_id'];?>" title="" data-toggle="tooltip" data-original-title="入库该书"><i class="mdi mdi-pencil"></i></a>
					  <?php }?>
                    </div>
                  </td>
                </tr>
                
				  <?php } ?>
				  	  
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript" src="/Public/Admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/popper.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/lyear-loading.js"></script>
<script type="text/javascript" src="/Public/Admin/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/main.min.js"></script>
<script type="text/javascript">
$(function(){
    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text());
    });
    
    // 通用ajax get请求
    jQuery(document).delegate('.ajax-get', 'click', function(){
        var self = $(this), tips = self.data('tips'), ajax_url = self.attr("href") || self.data("url");
        
        if (self.hasClass('confirm')) {
            $.confirm({
                title: '',
                content: tips || '确认要执行该操作吗？',
                type: 'orange',
                typeAnimated: true,
                buttons: {
                    confirm: {
                        text: '确认',
                        btnClass: 'btn-blue',
                        action: function() {
                            var loader = $('body').lyearloading({
                                opacity: 0.2,
                                spinnerSize: 'lg'
                            });
                            self.attr('autocomplete', 'off').prop('disabled', true);
                            
                            ajaxGetFun(self, ajax_url, loader);
                        }
                    },
                    cancel: {
                        text: '取消',
                        action: function() {}
                    }
                }
            });
            return false;
        } else {
            var loader = $('body').lyearloading({
                opacity: 0.2,
                spinnerSize: 'lg'
            });
            self.attr('autocomplete', 'off').prop('disabled', true);
            
            ajaxGetFun(self, ajax_url, loader);
        }
        return false;
    });
    

    
    // GET提交处理
    function ajaxGetFun(selfObj, ajax_url, loader) {
        console.log(ajax_url);
        jQuery.get(ajax_url).done(function(res) {
            loader.destroy();
            var res = eval('(' + res + ')');
            var msg = res.msg;
            if (200 == res.code) {
                if (res.url && !selfObj.hasClass('no-refresh')) {
                    msg += '页面即将自动跳转';
                }
                showNotify(msg, 'info');
                setTimeout(function () {
					selfObj.attr("autocomplete", "on").prop("disabled", false);
					return selfObj.hasClass("no-refresh") ? false : (res.url ? location.href = res.url : location.reload());
				}, 1500);
            } else {
                showNotify(msg, 'danger');
                selfObj.attr("autocomplete", "on").prop("disabled", false);
            }
        }).fail(function () {
            loader.destroy();
            showNotify('服务器发生错误，请稍后再试', 'danger');
            selfObj.attr("autocomplete", "on").prop("disabled", false);
        });
        
    }
  
    /*
     * 提取通用的通知消息方法
     * @param $msg 提示信息
     * @param $type 提示类型:'info', 'success', 'warning', 'danger'
     * @param $delay 毫秒数，例如：1000
     * @param $icon 图标，例如：'fa fa-user' 或 'glyphicon glyphicon-warning-sign'
     * @param $from 'top' 或 'bottom' 消息出现的位置
     * @param $align 'left', 'right', 'center' 消息出现的位置
     */
    function showNotify($msg, $type, $delay, $icon, $from, $align) {
        $type  = $type || 'info';
        $delay = $delay || 1000;
        $from  = $from || 'top';
        $align = $align || 'right';
        $enter = $type == 'danger' ? 'animated shake' : 'animated fadeInUp';

        jQuery.notify({
            icon: $icon,
            message: $msg
        },
        {
            element: 'body',
            type: $type,
            allow_dismiss: true,
            newest_on_top: true,
            showProgressbar: false,
            placement: {
                from: $from,
                align: $align
            },
            offset: 20,
            spacing: 10,
            z_index: 10800,
            delay: $delay,
            animate: {
                enter: $enter,
                exit: 'animated fadeOutDown'
            }
        });
    }
});
</script>
</body>
</html>